--[[ 编码: JX-800-05 名称: 出入库业务趋势 作者:SGX 日期:2025-1-29 函数: GenChartJson 功能: 叠折线图 更改记录: --]] json = require("json") mobox = require("OILua_JavelinExt") m3 = require("oi_base_mobox") function GenChartJson(strLuaDEID) local nRet, strRetInfo --[[ 标题颜色 ]] local strTitle = "出入库业务" --[[ 标题颜色 ]] local strColor = "#fff" --[[ 柱状图柱子名称,对应 series 下name ]] local tabLegendData = {'入库', '出库'} --[[ X轴数据 从左向右 ]] local tabXAxis = {'11-20', '11-21', '11-22', '11-23', '11-24', '11-25', '11-26', '11-27'} --[[ 入库颜色 ]] local strRKColor = '#EE822F' --[[ 出库颜色 ]] local strCKColor = '#F2BA02' --[[ 柱状图数据 对应X轴数据 ]] --[[入库 ]] local tabSeriesRKData = {220, 182, 191, 234, 290, 330, 310, 400} --[[ 出库]] local tabSeriesCKData = {120, 132, 101, 134, 90, 230, 210, 300} -- 做测试 页面动态定时刷新 值动态变化----------------------- local now = os.date("*t") -- 获取当前时间 local hour = now.hour local minute = now.min local second = now.sec -- 将时、分、秒组合成一个整数 local timeAsInteger = hour + second --[[入库 ]] tabSeriesRKData = {220, 182, 191, 234, 290, 330, 310, timeAsInteger+400} --[[ 出库]] tabSeriesCKData = {120, 132, 101, 134, 90, 230, 210, timeAsInteger+300} --------------------------------------------------------------------- local option = { title = { text = strTitle, left = 20, textStyle = { color = strColor }, top = 10 }, tooltip = { trigger = 'axis', axisPointer = { type = 'cross', label = { backgroundColor = '#6a7985' } } }, legend = { data = tabLegendData, textStyle = { color = strColor }, top = 10 }, grid = { left = '5%', right = '5%', bottom = '5%', top = '18%', containLabel = true }, xAxis = {{ type = 'category', boundaryGap = false, data = tabXAxis, axisLabel = { textStyle = { color = strColor } } }}, yAxis = {{ type = 'value', axisLabel = { textStyle = { color = strColor } }, splitLine = { show = false } }}, series = {{ name = '入库', type = 'line', stack = 'Total', areaStyle = {}, emphasis = { focus = 'series' }, label = { show = true }, color = strRKColor, data = tabSeriesRKData }, { name = '出库', type = 'line', stack = 'Total', areaStyle = {}, emphasis = { focus = 'series' }, label = { show = true }, color = strCKColor, data = tabSeriesCKData }} } local action = {} action[1] = { action_type = "chart", value = { graphicType = "echart", title = { text = strTitle, align = "center", color = "#515a6e", font = "微软雅黑", fontSize = 12 }, option = option } } lua.Debug(strLuaDEID, debug.getinfo(1), "action! ", action) nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action)) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. ' action = ' .. strAction) end end